<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录系统</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            background-color: #f4f4f4;
            margin: 0;
        }
        h1 {
            margin-bottom: 20px;
        }
        input {
            margin: 10px;
            padding: 10px;
            width: 200px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        button {
            padding: 10px;
            width: 220px;
            cursor: pointer;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            font-size: 16px;
        }
        button:hover {
            background-color: #0056b3;
        }
        .message {
            margin-top: 20px;
            font-size: 14px;
        }
    </style>
</head>
<body>
    <h1>登录系统</h1>
    <input type="text" id="username" placeholder="用户名">
    <input type="password" id="password" placeholder="密码">
    <button id="loginBtn">登录</button>
    <div class="message" id="message"></div>

    <script>
        // 预定义的有效用户名和密码
        const validCredentials = {
            "钟可怡": "123456",
            "冯浩哲": "123456"
        };

        // 获取登录按钮并添加点击事件监听器
        document.getElementById('loginBtn').addEventListener('click', function() {
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            const messageBox = document.getElementById('message');

            // 检查用户名和密码是否为空
            if (!username || !password) {
                messageBox.innerHTML = "用户名和密码不能为空！";
                messageBox.style.color = "red";
                return;
            }

            // 验证用户名和密码
            if (validCredentials[username] && validCredentials[username] === password) {
                messageBox.innerHTML = "登录成功！";
                messageBox.style.color = "green";
                // 这里可以添加后续操作，例如跳转到其他页面
            } else {
                messageBox.innerHTML = "用户名或密码错误！";
                messageBox.style.color = "red";
            }
        });
    </script>
</body>
</html>
